<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">全流程API订单列表</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="批量模式"
                                         icon="fa fa-list-ul"
                                         actionListener="#{loanApiOrderBean.changeModeToBatch}"
                                         update="@form"
                                         process="@this"
                                         rendered="#{loanApiOrderBean.isNotBatch()}"/>

                        <p:commandButton value="常规模式" icon="fa fa-file"
                                         actionListener="#{loanApiOrderBean.changeModeToNormal}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanApiOrderBean.isBatch()}"/>

                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>

                        <p:columnToggler datasource="loanApiOrderDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{loanApiOrderBean.onReset}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanApiOrderBean.isNormal() and security:areAllGranted('CHANNEL_PRODUCT_CHANNEL_SEARCH')}"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         ajax="false">
                            <p:dataExporter type="xls" target="loanApiOrderDataTable" fileName="export"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">


                                <p:outputLabel for="product">产品：</p:outputLabel>
                                <p:selectOneMenu id="product" value="#{loanApiOrderBean.$.productid}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{loanApiOrderBean.getCommProductIds()}"
                                            var="prd"
                                            itemLabel="#{prd.name}(#{prd.productId})"
                                            itemValue="#{prd.productId}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="channel">渠道：</p:outputLabel>
                                <p:selectOneMenu id="channel" value="#{loanApiOrderBean.$.channel}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{loanApiOrderBean.getCommProductChannels()}"
                                            var="channels"
                                            itemLabel="#{channels.channelName}(#{channels.channelCode})"
                                            itemValue="#{channels.channelCode}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="id" value="订单编号"/>
                                <p:inputText id="id" value="#{loanApiOrderBean.$.id}"/>
                                 
                                <p:outputLabel for="petname" value="姓名"/>
                                <p:inputText id="petname" value="#{loanApiOrderBean.$.petname}"/>
                                
                                <p:outputLabel for="mobnum" value="手机号码"/>
                                <p:inputText id="mobnum" value="#{loanApiOrderBean.$.mobnum}"/>
                                
                                <p:outputLabel for="idCard" value="身份证号码"/>
                                <p:inputText id="idCard" value="#{loanApiOrderBean.$.idCard}"/>
                                
                                <p:outputLabel for="status" value="订单状态"/>
                                <p:selectOneMenu id="status" value="#{loanApiOrderBean.$.status}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="- 待确认 -" itemValue="3" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="- 未通过 -" itemValue="4" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="- 待还款 -" itemValue="13" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="- 已结清 -" itemValue="15" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="- 待放款 -" itemValue="8" noSelectionOption="true"/>
                                </p:selectOneMenu>
                                
                                <p:outputLabel for="type" value="甲方名称"/>
                                <p:selectOneMenu id="type" value="#{loanApiOrderBean.$.type}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{loanApiOrderBean.dictionaries[DictionaryCode.WHOLEPROCESSOWNER]}"
                                            var="dic"
                                            itemLabel="#{dic.value1}" itemValue="#{dic.name}"/>
                                </p:selectOneMenu>
                                
                                <p:outputLabel for="startTime" value="申请时间"/>
                                <p:calendar id="startTime" value="#{loanApiOrderBean.$.startTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>
                                 <h:outputText value="至"/>
								 <p:calendar id="endTime" value="#{loanApiOrderBean.$.endTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>
                                

                                <p:outputLabel for="channelFrom" value="来源"/>
                                <p:inputText id="channelFrom" value="#{loanApiOrderBean.$.channelFrom}"/>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="loanApiOrderDataTable"
                                         style="width: 100%"
                                         var="loanApiOrder"
                                         value="#{loanApiOrderBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection="#{loanApiOrderBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="操作" rendered="#{loanApiOrderBean.isNotBatch()}">
                                    <p:splitButton icon="fa fa-eye"
                                                   action="#{loanApiOrderBean.onEdit(loanApiOrder.id)}"
                                                   process="@this">
                                        <f:setPropertyActionListener
                                                value="/views/family/loanapiorder/list.xhtml"
                                                target="#{currentUserBean.back}"/>
                                    </p:splitButton>
                                </p:column>
                                <p:column selectionMode="multiple" style="width:16px;text-align:center"
                                          rendered="#{loanApiOrderBean.isBatch()}"/>

                                <p:column headerText="产品">
                                    <h:outputText value="#{loanApiOrderBean.translateProduct(loanApiOrder.productId)}"/>
                                </p:column>

                                <p:column headerText="渠道">
                                    <h:outputText value="#{loanApiOrderBean.translateProductChannel(loanApiOrder.channel)}"/>
                                </p:column>

                                <p:column headerText="来源">
                                    <h:outputText value="#{loanApiOrder.channelFrom}"/>
                                </p:column>

                                <p:column headerText="订单编号">
                                    <h:outputText value="#{loanApiOrder.id}"/>
                                </p:column>
                                <p:column headerText="姓名">
                                    <h:outputText value="#{loanApiOrder.petname}"/>
                                </p:column>
                                <p:column headerText="手机号码">
                                    <h:outputText value="#{loanApiOrder.mobnum}"/>
                                </p:column>
                                <p:column headerText="身份证号码">
                                    <h:outputText value="#{loanApiOrder.idCard}"/>
                                </p:column>


                                <p:column headerText="放款金额">
                                    <h:outputText value="#{loanApiOrder.amount}"/>
                                </p:column>
                                <p:column headerText="总期限">
                                    <h:outputText value="#{loanApiOrder.peroid}"/>
                                </p:column>
                                <p:column headerText="当前期数">
                                    <h:outputText value="#{loanApiOrder.current_period}"/>
                                </p:column>

                                <p:column headerText="甲方名称">
                                    <h:outputText value="#{loanApiOrderBean.translateType(loanApiOrder.type)}"/>
                                </p:column>
                                <p:column headerText="订单状态">
                                    <h:outputText value="提单前" rendered="#{loanApiOrder.status == 1}"/>
                                    <h:outputText value="提单前" rendered="#{loanApiOrder.status == 2}"/>
                                    <h:outputText value="待确认" rendered="#{loanApiOrder.status == 3}"/>
                                    <h:outputText value="未通过" rendered="#{loanApiOrder.status == 4}"/>
                                    <h:outputText value="提单前" rendered="#{loanApiOrder.status == 5}"/>
                                    <h:outputText value="待确认" rendered="#{loanApiOrder.status == 6}"/>
                                    <h:outputText value="未通过" rendered="#{loanApiOrder.status == 7}"/>
                                    <h:outputText value="待放款" rendered="#{loanApiOrder.status == 8}"/>
                                    <h:outputText value="未通过" rendered="#{loanApiOrder.status == 9}"/>
                                    <h:outputText value="未通过" rendered="#{loanApiOrder.status == 10}"/>
                                    <h:outputText value="提单前" rendered="#{loanApiOrder.status == 11}"/>
                                    <h:outputText value="待还款" rendered="#{loanApiOrder.status == 12}"/>
                                    <h:outputText value="待还款" rendered="#{loanApiOrder.status == 13}"/>
                                    <h:outputText value="待还款" rendered="#{loanApiOrder.status == 14}"/>
                                    <h:outputText value="已结清" rendered="#{loanApiOrder.status == 15}"/>
                                    <h:outputText value="待确认" rendered="#{loanApiOrder.status == 16}"/>
                                    <h:outputText value="待还款" rendered="#{loanApiOrder.status == 17}"/>
                                    <h:outputText value="未通过" rendered="#{loanApiOrder.status == 18}"/>
                                    <h:outputText value="提单前" rendered="#{loanApiOrder.status == 19}"/>
                                </p:column>
                                <p:column headerText="申请时间">
                                    <h:outputText value="#{loanApiOrder.ctime}"/>
                                </p:column>
                                <p:column headerText="当前还款状态">
                                    <h:outputText value="部分还款" rendered="#{loanApiOrder.repay_status == 0}"/>
                                    <h:outputText value="已还清" rendered="#{loanApiOrder.repay_status == 1}"/>
                                    <h:outputText value="已逾期" rendered="#{loanApiOrder.repay_status == 2}"/>
                                    <h:outputText value="已还清" rendered="#{loanApiOrder.repay_status == 3}"/>
                                    <h:outputText value="已到期" rendered="#{loanApiOrder.repay_status == 5}"/>
                                </p:column>
                                <p:column headerText="订单详情">
                                    <p:commandLink id="OrderDetail" action="#{loanApiOrderBean.onOrderDetail(loanApiOrder.id)}" ajax="false">
                                        <h:outputText value="订单详情" />
                                    </p:commandLink>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
